﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:MVVMFramework.View">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/MVVMFramework.View;component/Themes/Colors.xaml"/>
        <ResourceDictionary Source="/MVVMFramework.View;component/Themes/Common.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="SpinnerButtonStyle" TargetType="RepeatButton">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Padding" Value="2,2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <!--Background="{TemplateBinding Background}"                                                                  
                                       CornerRadius="{DynamicResource {x:Static themes:ResourceKeys.SpinButtonCornerRadiusKey}}"
                                       RenderEnabled="{TemplateBinding IsEnabled}"
                                                RenderNormal="False"-->

                    <!--<chrome:ButtonChrome x:Name="Chrome"
                                       BorderBrush="{TemplateBinding BorderBrush}"                                                                                     
                                       RenderMouseOver="{TemplateBinding IsMouseOver}"
                                    
                                       RenderPressed="{TemplateBinding IsPressed}"
                                       SnapsToDevicePixels="true" />-->

                    <Border Name="border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding Background}">
                        <!--<Path x:Name="ArrowDownPath" Data="M2.5,0L8.5,0 5.5,3z" Fill="Black" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>-->


                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Margin="{TemplateBinding Padding}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource HoverInnerBackgroundBrush}"/>
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource CommonBorderBrush}"/>
                        </Trigger>

                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource PressedInnerBackgroundBrush}"/>
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource CommonBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:ButtonSpinner}">
        <Setter Property="Background" Value="{StaticResource ButtonInnerBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource CommonBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ButtonSpinner}">
                    <Grid SnapsToDevicePixels="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" />

                        <ContentPresenter Focusable="False" Margin="{TemplateBinding Padding}" 
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

                        <Grid Grid.Column="1" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource VisibleIfTrue}}" 
                              Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>

                            <RepeatButton x:Name="PART_IncreaseButton"
                                   Style="{StaticResource SpinnerButtonStyle}"
                                   BorderThickness="{TemplateBinding UpButtonBorderThickness}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource IncreaseGlyphNormalKey}" />

                            <RepeatButton x:Name="PART_DecreaseButton"
                                   Grid.Row="1"
                                  BorderThickness="{TemplateBinding DownButtonBorderThickness}"
                                   Style="{StaticResource SpinnerButtonStyle}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource DecreaseGlyphNormalKey}" />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource IsReadOnlyBackgroundBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_IncreaseButton" Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_IncreaseButton" Property="ContentTemplate" Value="{StaticResource IncreaseGlyphDisabledKey}" />
                        </Trigger>
                        <Trigger SourceName="PART_DecreaseButton" Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_DecreaseButton" Property="ContentTemplate" Value="{StaticResource DecreaseGlyphDisabledKey}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>